package com.course.db;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectDB {

	//
	String userName="root";
	//
	String userPassword="mysql";
	//
	String url="jdbc:mysql://localhost:3306/courseselective?useUnicode=true&characterEncoding=utf-8";
	//
	Connection dbConn;
	//
	String errMes;

   	public ConnectDB()
   	{
   		//
		errMes="";
   		dbConn=null;
   	}

	//
   	public Connection getConn()
   	{
	   	try
	   	{
			//
			Class.forName("com.mysql.jdbc.Driver");
			//
			dbConn= DriverManager.getConnection(url,userName,userPassword);
	   	}
	   	catch(Exception e)
	   	{
	   		dbConn = null;
	   		errMes=e.toString();
	   	}
	   	return dbConn;
   }

   //
   public String getErrMes()
   {
   		return errMes;
   }
}
